//
//  findCodeViewController.m
//  i读
//
//  Created by 123 on 15/10/20.
//  Copyright © 2015年 123. All rights reserved.
//

#import "findCodeViewController.h"
//#import "RequestManager.h"
//#import "SVProgressHUD.h"
//#import "LWUtils.h"
@interface findCodeViewController ()

@end

@implementation findCodeViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // 占字符颜色设置
    [_iPhoneField setValue:[[UIColor whiteColor] colorWithAlphaComponent:0.7] forKeyPath:@"_placeholderLabel.textColor"];
    [_identifyField setValue:[[UIColor whiteColor] colorWithAlphaComponent:0.7] forKeyPath:@"_placeholderLabel.textColor"];
    [_codeField setValue:[[UIColor whiteColor] colorWithAlphaComponent:0.7] forKeyPath:@"_placeholderLabel.textColor"];
    [_anyCodeField setValue:[[UIColor whiteColor] colorWithAlphaComponent:0.7] forKeyPath:@"_placeholderLabel.textColor"];
    
    //占字符字体大小设置
    [_iPhoneField setValue:[UIFont boldSystemFontOfSize:12] forKeyPath:@"_placeholderLabel.font"];
    [_identifyField setValue:[UIFont boldSystemFontOfSize:12] forKeyPath:@"_placeholderLabel.font"];
    [_codeField setValue:[UIFont boldSystemFontOfSize:12] forKeyPath:@"_placeholderLabel.font"];
    [_anyCodeField setValue:[UIFont boldSystemFontOfSize:12] forKeyPath:@"_placeholderLabel.font"];

    _codeField.secureTextEntry = YES;
    _anyCodeField.secureTextEntry = YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
 
}

#pragma  mark -         -------- 响应点击事件

//返回
- (IBAction)backButton:(UIButton *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark-           -------   取消键盘第一响应

// 点击任意位置是键盘消失
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    
    UITouch *touch = [touches anyObject];
    
    if (![touch.view isKindOfClass: [UITextField class]] || ![touch.view isKindOfClass: [UITextView class]]) {
        
        [self.view endEditing:YES];
        
    }
    
}

//#pragma mark -          --------    验证码事件
//
//- (IBAction)identifyBtn:(UIButton *)sender {
//    NSString *type = @"1";
//    if ([self.iPhoneField.text isEqualToString:@""]) {
//        [SVProgressHUD showErrorWithStatus:@"请输入手机号"];
//        
//        /******判断是否为合格手机号*******/
//    }else if ([LWUtils isMobileNumberClassification:self.iPhoneField.text]) {
//        
//        /****接口****/
//        [RequestManager getRegistCodeWithPhone:self.iPhoneField.text type:type
//                             completionHandler:^(NSString *reCode, NSString *reMsg) {
//                                 
//                                 //定时器设置
//                                 if ([reCode isEqualToString:@"0"]) {
//                                     __block int timeout=60; //倒计时时间
//                                     dispatch_queue_t queue  = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
//                                     dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue);
//                                     dispatch_source_set_timer(_timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒执行
//                                     dispatch_source_set_event_handler(_timer, ^{
//                                         if(timeout<=0){ //倒计时结束，关闭
//                                             dispatch_source_cancel(_timer);
//                                             dispatch_async(dispatch_get_main_queue(), ^{
//                                                 [_identifyBtn setTitle:@"获取验证码" forState:UIControlStateNormal];
//                                                 _identifyBtn.titleLabel.font = [UIFont boldSystemFontOfSize:14];
//                                                 _identifyBtn.userInteractionEnabled = YES;
//                                             });
//                                         }else{
//                                             int seconds = timeout % 60;
//                                             NSString *strTime = [NSString stringWithFormat:@"%.2d", seconds];
//                                             dispatch_async(dispatch_get_main_queue(), ^{
//                                                 //设置界面的按钮显示 根据自己需求设置
//                                                 [UIView beginAnimations:nil context:nil];
//                                                 _identifyBtn.titleLabel.text =[NSString stringWithFormat:@"%@秒后重新发送",strTime] ;
//                                                 [_identifyBtn setTitle:[NSString stringWithFormat:@"%@秒后重新发送",strTime] forState:UIControlStateNormal];
//                                                 _identifyBtn.titleLabel.font = [UIFont boldSystemFontOfSize:12];
//                                                 [UIView commitAnimations];
//                                                 _identifyBtn.userInteractionEnabled = NO;
//                                             });
//                                             timeout--;
//                                         }
//                                     });
//                                     dispatch_resume(_timer);
//                                 }
//                             }];
//    }else{
//        [SVProgressHUD showErrorWithStatus:@"请输入正确手机号"];
//    }
//    
//
//}
//
//#pragma mark -      --------- 提交
//
//- (IBAction)commitBtn:(UIButton *)sender {
//     if ([self checkPasswordAvailable]) {
//         
//         /****接口****/
//         [RequestManager resetPwdWithPhone:self.iPhoneField.text code:self.identifyField.text loginPwd:self.anyCodeField.text compaletionHandler:^(NSString *reCode, NSString *reMsg){
//             if ([reCode isEqualToString:@"0"]) {
//                 
//                  [self.navigationController popViewControllerAnimated:YES];
//             }
//       
//
//    }];
//     }
//}
//
//#pragma mark -      ---------  密码规范设置
//
//- (BOOL)checkPasswordAvailable{
//    if ([self.iPhoneField.text isEqualToString:@""]) {
//         [SVProgressHUD showErrorWithStatus:@"手机号不得为空"];
//        return  NO;
//    }
//    
//    if ([self.identifyField.text isEqualToString:@""]) {
//        [SVProgressHUD showErrorWithStatus:@"验证码不得为空"];
//        return  NO;
//    }
//    
//    if ([self.codeField.text isEqualToString:@""] && [self.anyCodeField.text isEqualToString:@""]) {
//        [SVProgressHUD showErrorWithStatus:@"密码不得为空"];
//        return NO;
//    }
//    
//    if (![self.codeField.text isEqualToString:self.anyCodeField.text]) {
//        [SVProgressHUD showErrorWithStatus:@"两次密码输入不一致!"];
//        return NO;
//    }
//    
//    if (![LWUtils isLetterWithDigital:self.codeField.text]) {
//        [SVProgressHUD showErrorWithStatus:@"密码格式不正确,只能为字母+数字组合!"];
//        return NO;
//    }
//    
//    if (self.codeField.text.length < 6 || self.codeField.text.length > 18) {
//        [SVProgressHUD showErrorWithStatus:@"密码长度为6-18位"];
//        return NO;
//    }
//    
//    
//    return YES;
//}

@end
